<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>小球半场运动</title>
    <link rel="stylesheet" href="../../vue文件/animate.css">
</head>
<style>
    #app{
        width: 100%;
        height: 100%;
    }
    .app{
        width: 20px;
        height: 20px;
        border-radius: 50%;
        background: red;
    }
    .gou{
        position: absolute;
        top: 325px;
        left: 300px;
        color: green;
        
    }
</style>
<body>
    <div id="app">
        <button @click="falg=true">+</button>
 
        <!-- 使用钩子函数来实现 -->
        <transition
        @before-enter="beforeEnter"
        @enter="enter"
        @after-enter="afterEnter"
        >
              <div class="app" v-if='falg' ></div>
              
        </transition>

        <div class="gou">购物车</div>
    </div>
</body>
<script src='../../vue文件/vue.js '></script>
<script>
    let vm = new Vue({
        el: '#app',
        data: {
             falg:false
        },
        methods: {
            beforeEnter(el){
                
                 el.style.transform='translate(0px,0px)'
            },
            enter(el,done){
                el.offsetWidth
                 el.style.transform='translate(300px,300px)'
                 el.style.transition="all 2s ease"
                 done()
            },
            afterEnter(el){
                this.falg=!this.falg
            }
        }
    })
</script>
</html>